<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/{$page_theme | default: 'default'}/easyui.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/style/my.css">
    
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/javascript/my.js"></script>
    
</head>
<body onpageshow="resetPagination('dg')">
    {datagrid id="dg" datasource="/flow/FlowInstanceService/findAll.do" view="flow_instance.view" }
    {form id="dlg" view="flow_instance.new" }
    {form id="dlg2" view="flow_instance.update" }
    
    <script>
    {literal}
    field_formatters.status=function (value, row, index){
    	if(value == 0) {
    		return "未开始";
    	} else if(value == 1) {
    		return "处理中";
    	} else if(value == 2) {
    		return "<font color='green'>成功结束</font>";
    	} else if(value == 3) {
    		return "<font color='red'>失败结束</font>";
    	}
    }
    field_formatters.business_type=function (value, row, index){
    	if(value == 'JY') {
    		return "车辆救援";
    	} else {
    		return value;
    	}
    }
    field_formatters.order_no=function (value, row, index){
    	return "<span onclick=openTasks('"+row.order_no+"',"+row.flow_instance_id+")>"+value+"<br><small>"+row['business_code']+"</small></span>";
    }
    field_formatters.emergency_level=function (value, row, index){
    	if(value == 3) {
    		return "<font color='red'>紧急</font>";
    	} else if(value == 2) {
    		return "中等";
    	} else {
    		return "一般";
    	}
    }
    field_formatters.priority_level=function (value, row, index){
    	if(value == 3) {
    		return "<font color='red'>高</font>";
    	} else if(value == 2) {
    		return "中";
    	} else {
    		return "低";
    	}
    }
    field_formatters.consume_seconds=function (value, row, index){
    	var days = 0;
    	var hours = 0;
    	var minutes = 0;
    	var seconds = value;
    	if(seconds > 60) {
    		minutes = Math.floor(seconds / 60);
    		seconds = seconds % 60;
    	}
    	if(minutes > 60) {
    		hours = Math.floor(minutes / 60);
    		minutes = minutes % 60;
    	}
    	if(hours > 24) {
    		days = Math.floor(hours / 24);
    		hours = hours % 24;
    	}
    	var res = "";
    	if(days > 0) res = days+"天";
    	if(hours > 0) res = res + hours+"小时";
    	if(minutes > 0) res = res + minutes+"分";
    	if(seconds > 0) res = res + seconds+"秒";
    	return res;
    }
    //编辑器
    action_prehandlers.updateOne=function(){
        var row = $('#dg').datagrid('getSelected');
        if (row){
            alert(row.summary);
            editor.html(row.summary);
        }
    	return {};
    }
    function showTasks() {
	    var row = getDatagrid('dg').datagrid('getSelected');
	    if(row) {
	    	openTasks(row.order_no, row.flow_instance_id);
	    } else {
			alert('没有选择工单！');
	    }
    }
    function openTasks(order_no, flow_instance_id) {
    	window.parent.openTab(order_no+'的任务','/flow/admin/flow_instance_tasks.shtml?flow_instance_id='+flow_instance_id);
    }
    {/literal}
    </script>
</body>
</html>